import React from 'react';
import CommonList from '../../../../components/CommonLists/list';
import Modal from '../../../../components/Modal';
import { Tooltip, Button } from 'antd';
import Compare from './compare';
class ApplicationList extends CommonList {
  constructor(props) {
    super(props);
    this.api = 'indicator';
    this.id = props.feature_id
    this.tableClass = '';
    this.delButton = false;
    this.columns = [
      // {
      //   dataIndex: 'is_current',
      //   key: 'is_current',
      //   render: text => {
      //     return <>{text === GLOBAL_TRUE_FALSE._TRUE ? <span>当前</span> : <span></span>}</>;
      //   }
      // },
      {
        title: '版本号',
        dataIndex: 'version',
        key: 'version'
      },
      {
        title: '修改人',
        key: 'update_user_name',
        dataIndex: 'update_user_name',
        ellipsis: true,
        render: text => {
          return (
            <Tooltip title={text} placement='topLeft'>
              <div className='overflowtext' style={{ width: '100%' }}>
                {text}
              </div>
            </Tooltip>
          );
        }
      },
      {
        title: '修改时间',
        dataIndex: 'update_time',
        key: 'update_time',
        ellipsis: true,
        width: 150,
        render: (text, record) => {
          var content = !!record.update_time ? record.update_time : record.create_time;
          return (
            <Tooltip title={content} placement='topLeft'>
              <div className='overflowtext' style={{ width: '100%' }}>
                {content}
              </div>
            </Tooltip>
          );
        }
      }
    ];
    this.compareButton = record => {
      return (
        <Button size='small' type='link' onClick={this.compare.bind(this, record)}>
          对比
        </Button>
      );
    };

    this.btnGroup = [this.compareButton];
  }
  componentDidMount() {}

  compare = record => {
    Modal.open({
      title: '版本对比',
      isOkBtn: true,
      isCancelBtn: true,
      width: 1000,
      maskClosable: true,
      ok: () => {
        Modal.close();
      },
      cancel: () => {
        Modal.close();
      },
      content: <Compare feature_id={this.id} version={record.version} />
    });
  };
}

export default ApplicationList;
